﻿using FluentValidation;
using MediatR;

namespace Wips.AppService.Publisher.Requests
{
    /// <summary>
    /// 保存文本内容
    /// </summary>
    public class AgentSaveFileTextRequest : IRequest<string>
    {
        /// <summary>
        /// id
        /// </summary>
        public string Id { get; set; } = "";

        /// <summary>
        /// 路径
        /// </summary>
        public string Path { get; set; } = "";

        /// <summary>
        /// 内容
        /// </summary>
        public string Content { get; set; } = "";
    }

    /// <summary>
    /// 校验
    /// </summary>
    public class SaveFileTextRequestVaildator : AbstractValidator<AgentSaveFileTextRequest>
    {
        /// <summary>
        /// 
        /// </summary>
        public SaveFileTextRequestVaildator()
        {
            RuleFor(p => p.Id)
                .Must(p => !string.IsNullOrEmpty(p))
                .WithMessage("Id不能为空");

            RuleFor(p => p.Path)
            .Must(p => !string.IsNullOrEmpty(p))
            .WithMessage("Path不能为空");

            RuleFor(p => p.Content)
            .Must(p => !string.IsNullOrEmpty(p))
            .WithMessage("Content不能为空");


        }
    }
}
